<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Observer - fullPage.js</title>
	<meta name="author" content="Alvaro Trigo Lopez" />
	<meta name="description" content="fullPage.js using CSS3 transformations." />
	<meta name="keywords"  content="fullpage,jquery,anchor,links,inside,demo,css,css3" />
	<meta name="Resource-type" content="Document" />


	<link rel="stylesheet" type="text/css" href="../dist/fullpage.css" />
	<link rel="stylesheet" type="text/css" href="examples.css" />
    <style>
        /* Hidding sections under 960px width */
        @media screen and (max-width: 960px) {
            .hide-on-responsive{
                display: none;
            }
        }

        #fp-nav ul li a span, 
        .fp-slidesNav ul li a span{
            background-color: white;
        }
        

        .actions{
            position: absolute;
            z-index: 999;
            top: 40px;
            left: 50px;
        }
        .actions li{
            display: inline-block;
        }
        .actions button {
            padding: 0.93em 1.87em;
            background: #35495e;
            border-radius: 5px;
            border: 0;
            color: #fff;
            margin: 7px;
            font-size: 15px;
            cursor: pointer;
        }

        .actions button:hover {
            background: #fff;
            color: #35495e;
        }
    </style>
</head>
<body>

<ul class="actions">
    <li><button data-type="section">Add section</button></li>
    <li><button data-type="slides">Add 2 new slides</button></li>
    <li><button data-type="remove">Remove Current</button></li>
</ul>


<select id="demosMenu">
    <option selected>Choose Demo</option>
    <option id="simple">Simple</option>
    <option id="custom-arrows">Custom arrows</option>
    <option id="hide-sections">Hide sections</option>
    <option id="scroll-after-fullpage">Scroll after fullpage</option>
    <option id="observer">Observer</option>
    <option id="jquery-adapter">jQuery adapter</option>
    <option id="active-slide">Active section and slide</option>
    <option id="auto-height">Auto height</option>
    <option id="autoplay-video-and-audio">Autoplay Video and Audio</option>
    <option id="backgrounds">Background images</option>
    <option id="backgrounds-fixed">Fixed fullscreen backgrounds</option>
    <option id="background-video">Background video</option>
    <option id="callbacks">Callbacks</option>
    <option id="continuous-horizontal">Continuous horizontal (premium)</option>
    <option id="continuous-vertical">Continuous vertical</option>
    <option id="parallax">Parallax (premium)</option>
    <option id="cards">Cards 3d (premium)</option>
    <option id="water-effect">Water effect (premium)</option>
    <option id="drop-effect">Drop effect (premium)</option>
    <option id="css3">CSS3</option>
    <option id="drag-and-move">Drag And Move (premium)</option>
    <option id="easing-css3">Easing CSS</option>
    <option id="easing-js">Easing JS</option>
    <option id="fading-effect">Fading Effect (premium)</option>
    <option id="fixed-headers">Fixed headers</option>
    <option id="gradient-backgrounds">Gradient backgrounds</option>
    <option id="interlocked-slides">Interlocked Slides (premium)</option>
    <option id="looping">Looping</option>
    <option id="methods">Methods</option>
    <option id="navigation-vertical">Vertical navigation dots</option>
    <option id="navigation-horizontal">Horizontal navigation dots</option>
    <option id="navigation-tooltips">Navigation tooltips</option>
    <option id="no-anchor">No anchor links</option>
    <option id="normal-scroll">Normal scrolling</option>
    <option id="normalScrollElements">Normal scroll elements</option>
    <option id="offset-sections">Offset sections (premium)</option>
    <option id="one-section">One single section</option>
    <option id="reset-sliders">Reset sliders (premium)</option>
    <option id="responsive-auto-height">Responsive Auto Height</option>
    <option id="responsive-height">Responsive Height</option>
    <option id="responsive-width">Responsive Width</option>
    <option id="responsive-slides">Responsive Slides (premium)</option>
    <option id="scrollBar">Scroll bar enabled</option>
    <option id="scroll-horizontally">Scroll horizontally (premium)</option>
    <option id="scrollOverflow">Scroll inside sections and slides</option>
    <option id="scrollOverflow-reset">ScrollOverflow Reset (premium)</option>
    <option id="lazy-load">Lazy load</option>
    <option id="scrolling-speed">Scrolling speed</option>
    <option id="trigger-animations">Trigger animations</option>
    <option id="vue-fullpage">Vue component</option>
    <option id="react-fullpage">React component</option>
    <option id="angular-fullpage">Angular component</option>
  </select>


<div id="fullpage">
    <div class="section">
        <h1>fullPage.js 1</h1>
		    <p>
                Hide, add or modify sections.<br>
                fullPage.js will get updated automatically.
            </p>
    </div>
	<div class="section" id="section0">
        <div class="slide">
            <h1>fullPage.js 2</h1>
		    <p>
                Hide, add or modify sections.<br>
                fullPage.js will get updated automatically.
            </p>
        </div>
        <div class="slide">
            <h1>Cool uh?</h1>
		    <p>fullPage.js listen to your DOM!</p>
        </div>

		
	</div>
	<div class="section hide-on-responsive" id="section1">
		<div class="intro">
			<h1>To Hide On Responsive</h1>
			<p>
                This section will get hidden when reaching 960px width.<br />
                We are using CSS to hide the sections. <br />
                But fullPage.js will notice the change and update accordingly.
			</p>
		</div>
	</div>
	<div class="section " id="section2">
		<div class="intro">
			<h1>Check it out!</h1>
			<p>You'll love it</p>
		</div>
	</div>
</div>

<script type="text/javascript" src="../dist/fullpage.js"></script>
<script type="text/javascript" src="examples.js"></script>
<script type="text/javascript">
    var myFullpage = new fullpage('#fullpage', {
        sectionsColor: ['#1bbc9b', '#4BBFC3', '#7BAABE', '#435b71', 'orange', 'blue', 'purple', 'yellow', '#435b71', 'orange', 'blue', 'purple', 'yellow' ],
        anchors: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'],
        controlArrows: false,
        navigation: true,
        slidesNavigation: true
    });


    document.querySelectorAll('button').forEach(function(button){
        button.addEventListener('click', onActionClick);
    });

    
    function onActionClick(e){
        var type = e.target.getAttribute('data-type');
        let activeSection;

        switch(type){
            case 'section':
                var anchorId = "new-anchor-" + document.querySelectorAll('.fp-section').length;
                document.querySelector('#fullpage').innerHTML += '<div class="section" data-anchor="'+ anchorId +'"><h1>New section</h1></div>';

                break;

            case 'slides':
                activeSection = document.querySelector('.fp-section.active');
                const newSlides = '<div class="slide"><h1>New slide 1.1</h1></div><div class="slide"><h1>New slide 1.2</h1></div>';
                if(activeSection.querySelector('.fp-slide')){
                    activeSection.querySelector('.fp-slidesContainer').innerHTML += newSlides;
                }
                else{
                    activeSection.innerHTML = newSlides;
                }

                break;

            case 'remove':
                activeSection = document.querySelector('.fp-section.active');
                const numSlides = activeSection.querySelectorAll('.fp-slide').length;
                const activeSlide = activeSection.querySelector('.fp-slide.active');
                const toRemove = numSlides > 1 ? activeSlide : activeSection;

                toRemove.parentNode.removeChild(toRemove);

                break;
        }
    }

</script>

</body>
</html>
